package com.zerox.service.impl;


import com.zerox.entity.SysRole;
import com.zerox.mapper.SysRoleMapper;
import com.zerox.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Autowired
    private SysRoleMapper sysRoleMapper;

    @Override
    public List<SysRole> roleByname() {
        return sysRoleMapper.roleByName();
    }

    @Override
    public List<SysRole> listRole(Integer startIndex2, Integer pageSize2, String roleName) {
        if(Objects.isNull(startIndex2)){
            startIndex2 = 1;
        }
        if(Objects.isNull(pageSize2)){
            pageSize2 = 10;
        }
        int pageIndex = (startIndex2-1)*pageSize2;
        return sysRoleMapper.listRole(pageIndex, pageSize2,roleName);
    }


    @Override
    public int count() {
        return sysRoleMapper.count();
    }

    @Override
    public int add(SysRole subject) {
        return sysRoleMapper.add(subject);
    }

    @Override
    public int delete(Integer roleId) {
        return sysRoleMapper.delete(roleId);
    }

    @Override
    public SysRole selectById(Integer roleId) {
        return sysRoleMapper.selectById(roleId);
    }

    @Override
    public int update(SysRole sysRole) {
        return sysRoleMapper.update(sysRole);
    }
}
